<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>锐信内容管理系统-修改产品信息</title>
<%@include file="/WEB-INF/pages/common/taglibs.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}resources/css/screen.css" />
<link rel="stylesheet" type="text/css" href="${ctx}resources/css/list.css" />
<script type="text/javascript" src="${ctx}resources/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}resources/js/jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}resources/css/uploadify.css" /> 
<style>
.sing {
	width: 200px;
	height: 25px;
}
input {
	border:#999 1px solid;
}
</style>
<script type="text/javascript">
$().ready(function() {
	$("#signupForm").validate({
		rules: {
			name: {
				required: true,
				minlength:2,
				remote:{
				　　url:"${ctx}/product/checkName.htm", 
					   dataType:"json",
					   type:"post",
				　　data:{
						 	name:function(){
						 		return $("#name").val();
						 	},
						 	id:function(){
						 		return $("#id").val();
						 	}
					 	}
			　 }
			},
			description: {
				required: true
			}
		},
		messages: {
			name: {
				required: "*产品名称不能为空！",
				minlength:"*产品名称长度应该大于2个字符！",
				remote:"*该产品名称已经存在，请换其他名称！"
			},
			description: {
				required: "*描述不能为空！"
			}
		}
	});

   $('#uploadify').uploadify({
   	 'formData': {'id':"${product.id}",'uploader':'productlogo'},
       'swf': '${ctx}resources/js/uploadify.swf',
       'method':'post',
       'buttonText':'上传',
       'fileObjName':'attachment',
       'uploader':'${ctx}attach/pic/upload.htm;jsessionid=${sessionId}',
       'onUploadError': function(a, b, c, d){
       	alert("上传失败");
       },'onUploadSuccess' : function(file, data, response) {
           $("#logo").val(data);
           $("#imgs").attr('src',"${ctx}"+data); 
       }
   });
});
</script>
</head><body>
<div align="center" style="padding-top:20px;">
  <form  id="signupForm" method="post" action="${ctx}product/save.htm">
    <input type="hidden" name="logo" id="logo"  value="${product.logo}"/>
    <input type="hidden" value="${product.id}" name="id" id="id">
    <input type="hidden" value="${pageNo}" name="pageNo" id="pageNo">
    <table width="95%" cellpadding="0" cellspacing="1" align="center" id="bordertable">
      <tr class="tr0" height="40">
        <td  style="  text-align: right;"><label>产品名称:</label></td>
        <td align="left" width="60%"><input id="name" name="name" value="${product.name}" class="sing"></td>
      </tr>
      <tr class="tr0" height="40" >
        <td  style="  text-align: right;"><label>产品状态:</label></td>
        <td align="left" width="60%" >
			<select class="sing" name="status">
				<option value="1"  <c:if test="${product.status}">selected</c:if>>上线</option>
				<option value="0" <c:if test="${!product.status}">selected</c:if>>下线</option>
			</select>
		</td>
      </tr>
      <tr class="tr0" height="40">
        <td  style="  text-align: right;"><label>产品类型:</label></td>
        <td align="left" width="60%">
			<select class="sing" name="productType">
				<option value="ANDROID"  ${product.productType.label eq "ANDROID" ? "selected":""}>安卓</option>
				<option value="IPHONE"   ${product.productType.label eq "IPHONE" ? "selected":""}>iphone</option> 
				<option value="WINDOWS"  ${product.productType.label eq "WINDOWS"?"selected":""}>windows</option>
				<option value="IPAD"  ${product.productType.label eq "IPAD" ? "selected":""}>ipad</option>
				<option value="OTHER"  ${product.productType.label eq "OTHER"?"selected":""}>其他</option>
			</select>
		</td>
      </tr>
      
      <tr class="tr0" height="40" >
        <td  style="  text-align: right;"><label>产品描述:</label></td>
        <td align="left" width="60%">
			<textarea rows="5" cols="40" name="description" id="description" >${product.description}</textarea>
		</td>
      </tr>
      
      <tr class="tr0" height="40">
        <td  style="  text-align: right;"><label>产品LOGO:</label>
        </td>
        <td width="60%">
        	<div><img alt="该APP还没有LOGO" id="imgs" src=" ${ctx}${product.logo}" style="width: 100px;height: 100px;"/><input type="file" name="attachment" id="uploadify" style="width: 100px;"/></div>
		</td>
      </tr>
     <tr height="70px;"  class="tr0">
			<td style="padding-right: 20px;text-align: right; height:50px;"><input class="button" type="submit" value="提交"/></td>
			<td style="padding-left: 20px;text-align: left; height:50px;"><input class="button"  type="reset" value="取消" onclick="javascript:history.back();"/></td>
		</tr>
    </table>
  </form>
</div>
</body>
</html>